﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Globalization;
using PromotionApp.Utility;

namespace PromotionApp.UserControl
{
    public partial class ucDatePicker : System.Web.UI.UserControl
    {
        #region Property

        public string SelectDateText
        {
            get
            {
                return txtDate.Text;
            }
            set
            {
                txtDate.Text = value;
            }
        }

        public DateTime SelectedDate
        {
            get
            {
                return DateTime.ParseExact(txtDate.Text, ConfigurationHelper.DateDisplayFormat, CultureInfo.CurrentCulture);
            }
            set
            {
                txtDate.Text = value.ToString(ConfigurationHelper.DateDisplayFormat, CultureInfo.CurrentCulture);
            }
        }

        public bool Enabled
        {
            get
            {
                return ibSelectDate.Enabled;
            }
            set
            {
                ibSelectDate.Enabled = value;
            }
        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack)
                txtDate.Text = Request[txtDate.UniqueID];
            else
                this.CalendarExtender1.Format = ConfigurationHelper.DateDisplayFormat;
        }
    }
}